package cn.ruituo.adv5;
import java.io.*;
public class TestUTfASI {
    //ANSI到utf-8的转换
    public static void main(String[] args) throws  Exception {
        File srcFile = new File("222.txt");
        File destFile = new File("1111.txt");
        InputStreamReader isr = new InputStreamReader(new FileInputStream(srcFile), "GBK"); //ANSI编码
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(destFile), "UTF-8"); //存为UTF-8

        int len =0;
        while((len = isr.read())!=-1)
        {
            osw.write(len);
        }
        //刷新缓冲区的数据，强制写入目标文件
        osw.flush();
        osw.close();
        isr.close();

    }
}
